{extend name="./oscshop/admin/view/public/base.html" /}
{block name="content"}	
<div class="page-header">
	<h1>
		{$breadcrumb1}
		<small>
			<i class="ace-icon fa fa-angle-double-right"></i>
			{$breadcrumb2}
		</small>
	</h1>
</div>	
<table class="table table-striped table-bordered table-hover search-form">
	<thead>
		<th><input name="order_num" type="text" placeholder="输入订单号" value="{:input('param.order_num')}" /><input name="user_name" type="text" placeholder="输入会员名" value="{:input('param.user_name')}" />    				
			<select name="status">
				<option value="">-选择状态-</option>
				<?php $search_status=input('param.status'); ?>
				{volist name="status" id="v" }
					<option <?php if($search_status==$v['order_status_id']){echo ' selected="selected"';} ?> value="{$v.order_status_id}">{$v.name}</option>
				{/volist}	
			</select>
   				
			<select name="pay_subject">
				<option value="">-选择商品名称-</option>
				<?php $pay_subject=input('param.pay_subject'); ?>
				{volist name="subject" id="v" }
					<option <?php if($pay_subject==$v['pay_subject']){echo ' selected="selected"';} ?> value="{$v.pay_subject}">{$v.pay_subject}</option>
				{/volist}	
			</select>
   				
			<select name="type">
				<option value="">-订单类型-</option>
					
					<?php $type=input('param.type'); ?>								
					{volist name="goods_type" id="t"}
						<option {if condition="$type eq $t['id']"} selected="selected"{/if} value="{$t.id}">{$t.name}</option>
					{/volist}
					
			</select>
			</th>	
		<th>
			支付时间从<input name="begin_time" type="date" placeholder="开始时间" value="{:input('param.begin_time')}" />开始
		至<input name="end_time" type="date" placeholder="结束时间" value="{:input('param.end_time')}" />之前</th>	
		</th>
		<th>
			<a class="btn btn-primary" href="javascript:;" id="search" url="{:url('OrderBackend/index')}">查询</a>
		</th>
		<th>
			<a class="btn btn-primary" href="javascript:;" id="export" url="/admin/export/export_order">导出清单</a>
		</th>

	</thead>
</table>	
	
<div class="row">
	<div class="col-xs-12">	
		<div class="table-responsive">
			<table class="table table-striped table-bordered table-hover">
				<thead>
					<tr>											
						<th>ID</th>
						<th>订单号</th> 
						<th>商品名</th> 
						<td>类型</td>
						<th>支付方式</th> 
						<th>总计</th> 						
						<th>会员名</th>					
						<th>状态</th>	
						<th>下单时间</th>	
						<th>支付时间</th>				
						<th>操作</th>	
					</tr>
				</thead>
				<tbody>
						{volist name="list" id="v" empty="$empty"}
						<tr>						
							<td>{$v.order_id}</td>
							<td>{$v.order_num_alias}
								{if condition="$v['shipping_method'] eq ''"}
								<span style="border:1px solid red;color:#f60;">免运输</span>
								{/if}
								{if condition="$v['free_shipping'] eq 1"}
								<span style="border:1px solid red;color:#f60;">免运费</span>
								{/if}
							</td>	
							<td>{$v.pay_subject}	</td>
							<td>
								{:get_goods_type($v['type'])}
							</td>
							<td>
								{if condition="$v['payment_code'] eq 1"}
								通证消费
								{else}
								消费积分消费
								{/if}
							</td>

							<td>							
								{$v['total']}
							</td>
							<td>
								{if condition="$v['reg_type'] NEQ 'weixin'"}
									{$v.username}
								{else/}
									{$v.nickname}（微信用户）
								{/if}
							</td>
							<td>{:get_order_status_name($v['order_status_id'])}
								
								{if condition="$v['order_status_id'] eq config('shipping_order_status_id')"}
								<br/>
								快递公司：{:osc_system()->get_express($v['transport_c_name'])}
								<br/>
								快递单号：{$v.transport_num}
								{/if}</td>
							<td>
								<?php echo date('Y-m-d H:i:s',$v['date_added']); ?>
							</td>
							<td>
								<?php echo date('Y-m-d H:i:s',$v['pay_time']); ?>
							</td>
							<td>
								<a  class="btn btn-xs btn-info" href='{:url("OrderBackend/show_order",array("id"=>$v["order_id"]))}'>
									<i class="fa fa-eye bigger-120"></i>
								</a> 
								{if condition="$v['shipping_method']"}
								<a  class="btn btn-xs btn-info" href='{:url("OrderBackend/print_order",array("id"=>$v["order_id"]))}'>
									<i class="fa fa-print bigger-120"></i>
								</a> 
								{/if}
								<!-- <a class="delete btn btn-xs btn-danger" href='{:url("OrderBackend/del",array("id"=>$v["order_id"]))}' >
									<i class="fa fa-trash bigger-120"></i>
								</a> -->
							</td>
						</tr>
						{/volist}	
						
						<tr>
							<td colspan="20" class="page">{$list->render()}</td>
						</tr>
				</tbody>
				
			</table>
		</div>
	</div>
</div>
{/block}
{block name="javascript"}
<script>	
$(function(){
   $("#search").click(function () {
        var url = $(this).attr('url');
        var query = $('.search-form').find('input,select').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
        query = query.replace(/^&/g, '');
        if (url.indexOf('?') > 0) {
            url += '&' + query;
        } else {
            url += '?' + query;
        }
        window.location.href = url;
    });	
});
$(function(){
   $("#export").click(function () {
        var url = $(this).attr('url');
        var query = $('.search-form').find('input,select').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
        query = query.replace(/^&/g, '');
        if (url.indexOf('?') > 0) {
            url += '&' + query;
        } else {
            url += '?' + query;
        }
        window.location.href = url;
    });	
});
</script>
{/block}